import { BrowserRouter, Routes, Route } from 'react-router-dom';
import AuthRoute from './components/AuthRoute';
import { authRoutes, publicRoutes } from './router';

function App() {
  return (
    <BrowserRouter>
      <Routes>
        {/* 公共路由 */}
        {publicRoutes.map((route) => (
          <Route
            key={route.path}
            path={route.path}
            element={route.element}
          />
        ))}

        {/* 需要登录权限的路由 */}
        {authRoutes.map((route) => (
          <Route
            key={route.path}
            path={route.path}
            element={<AuthRoute>{route.element}</AuthRoute>}
          />
        ))}
      </Routes>
    </BrowserRouter>
  );
}

export default App;
